#ifndef LOADING_H
#define LOADING_H

#include <QWidget>
#include <QPaintEvent>
#include <QPainter>
#include <QTimer>
#include "globaldef.h"
#include "project.h"

namespace Ui {
class Loading;
}

class Loading : public QWidget
{
    Q_OBJECT

public:
    //单例模式,保证一个程序只存在一个Loading实例对象
    static Loading *Instance(QWidget *parent = nullptr, QColor maskColor = QColor(0, 0, 0, 50), bool touchThrough = false, QString label = QString(tr("加载中")));
    explicit Loading(QWidget *parent = nullptr, QColor maskColor = QColor(0, 0, 0, 50), bool touchThrough = false, QString label = QString(tr("加载中")));
    ~Loading();
    static void showLoading(QColor maskColor = QColor(0, 0, 0, 50), bool touchThrough = false, QString label = QString(tr("加载中")));
    static void hideLoading();

public slots:
    void rotateImage();
protected:
    void paintEvent(QPaintEvent *event);

private:
    static Loading *self;
    Ui::Loading *ui;
    QTimer *timer;
    QPixmap mPix;
    QColor maskColor;
};

#endif // LOADING_H
